
import request from '@/utils/request.js'

export const getArticles = params => {
  return request({
    url: 'app/v1_1/articles',
    params
  })
}

/**
 * 获取文章详情
 **/
export const getArticleById = articleId => {
  return request({
    method: 'GET',
    url: `app/v1_0/articles/${articleId}`
  })
}

// 添加收藏
export const addArticleCollected = (artId) => {
  return request({
    url: 'app/v1_0/article/collections',
    method: 'POST',
    data: {
      target: artId
    }
  })
}

// 取消收藏
export const deleteArticleCollected = (artId) => {
  return request({
    url: `app/v1_0/article/collections/${artId}`,
    method: 'DELETE'
  })
}

// 点赞
export const addArticleLike = (artId) => {
  return request({
    url: 'app/v1_0/article/likings',
    method: 'POST',
    data: {
      target: artId
    }
  })
}

// 取消点赞
export const deleteArticleLike = (artId) => {
  return request({
    url: `app/v1_0/article/likings/${artId}`,
    method: 'DELETE'
  })
}
